<?php

namespace app\api\validate;

use think\Validate;

class Student extends Validate
{
    protected $rule =   [
        'title'         => 'require|max:30',
        'course_id'     => 'require|number|notin:0',
        'id'            => 'require|number|notin:0',
        'source_id'     => 'require|number|notin:0',
        'gender'        => 'require|in:0,1',
        'truename'      => 'require|chs|min:2',
        'referrer'      => 'require|chs',
        'account'       => 'require|mobile',
        'birthday'      => 'require|date',
        'apply_time'    => 'require|date',
        'semester_id'   => 'require|number|notin:0',
        'city_code'     => 'require|number|min:6',
        'province_code' => 'require|number|min:6',
        'name' => 'require|chs',
        'page' => 'require|number|notin:0',
        'size' => 'require|number|notin:0'
    ];

    protected $message  =   [
        'city_code.require' => '城市编码不能为空',
        'city_code.number'  => '城市编码参数错误', 
        'city_code.min'     => '城市编码限制6个字符', 

        'province_code.require' => '省编码不能为空',
        'province_code.number'  => '省编码参数错误', 
        'province_code.min'     => '省编码限制6个字符', 

        'semester_id.require' => '学期参数不能为空',
        'semester_id.number'  => '学期参数错误',
        'semester_id.notin'   => '学期参数错误',

        'apply_time.require' => '报名日期不能为空',
        'apply_time.date'    => '填写正确日期格式',

        'course_id.require' => '课程参数不能为空',
        'course_id.number'  => '课程参数错误',
        'course_id.notin'   => '课程参数错误',

        'source_id.require' => '来源参数不能为空',
        'source_id.number'  => '来源参数错误',
        'source_id.notin'   => '来源参数错误',

        'gender.in'      => '性别参数错误',
        'gender.require' => '性别不能为空',

        'referrer.require' => '推荐人姓名不能为空',
        'referrer.chs'     => '推荐人姓名请输入中文',


        'truename.require' => '姓名不能为空',
        'truename.chs'     => '姓名请输入中文',
        'truename.min'     => '姓名最少为两个中文字符',

        'account.require' => '手机号不能为空',
        'account.mobile'  => '填写正确手机号',

        'birthday.require' => '日期不能为空',
        'birthday.date'    => '填写正确日期格式',

        'name.require' => '搜索姓名不能为空',
        'name.chs'     => '搜索姓名请输入中文',

        'page.require' => '分页参数不能为空',
        'page.number'  => '分页参数错误',
        'page.notin'   => '分页参数错误',

        'size.require' => '分页参数不能为空',
        'size.number'  => '分页参数错误',
        'size.notin'   => '分页参数错误',

        'id.require' => '缺失id参数',
        'id.number'  => 'id参数错误',
        'id.notin'   => 'id参数错误',

    ];

    protected $scene = [
        // 添加周期
        'createStudent' => ['truename', 'account', 'course_id', 'gender', 'birthday', 'source_id', 'referrer','apply_time','semester_id','city_code','province_code'],
        'updateStudent' => ['truename', 'account', 'course_id', 'gender', 'birthday', 'id', 'source_id', 'referrer','apply_time','semester_id','city_code','province_code'],
        'checkName' => ['name'],
        'checkProvince_code' => ['province_code'],
        'checkCity_code' => ['city_code'],
        'search' => ['page', 'size']
    ];
}
